Component({
    properties: {
        question: {
            type: Object,
            value: {}
        },
        answer: {
            type: Object,
            value: {}
        },
        site: {
            type: Number,
            value: 0
        }
    },
    data: {
        selectedArr: []
    },
    ready: function() {
        console.log(this.data.answer.option);
        var t = this.data.answer.option;
        console.log(t);
        for (var o = this.data.question, e = function(e) {
            t.some(function(t) {
                return t.option_id == o.option[e].option_id;
            }) && (o.option[e].selected = !0);
        }, i = 0; i < o.option.length; i++) e(i);
        this.setData({
            question: o,
            selectedArr: t
        });
    },
    methods: {
        selectedItem: function(t) {
            console.log(t.currentTarget.dataset.item);
            var o = t.currentTarget.dataset.item, e = this.data, i = e.selectedArr, n = e.question;
            if (1 == n.is_option) {
                var s = i.some(function(t) {
                    return t.option_id == o.option_id;
                });
                if (0 != i.length) {
                    for (var r = 0; r < n.option.length; r++) n.option[r].option_id == i[0].option_id && (n.option[r].selected = !1);
                    i = [];
                }
                if (console.log(s), !s && !i.some(function(t) {
                    return t.option_id == o.option_id;
                })) {
                    delete o.selected, i.push(o);
                    for (var p = 0; p < n.option.length; p++) n.option[p].option_id == o.option_id && (n.option[p].selected = !0);
                }
            } else if (2 == n.is_option) if (i.some(function(t) {
                return t.option_id == o.option_id;
            })) {
                for (var a = 0; a < n.option.length; a++) n.option[a].option_id == o.option_id && (n.option[a].selected = !1);
                i.forEach(function(t, e) {
                    t.option_id == o.option_id && i.splice(e, 1);
                });
            } else {
                i.push(o);
                for (var d = 0; d < n.option.length; d++) n.option[d].option_id == o.option_id && (n.option[d].selected = !0);
            }
            this.setData({
                question: n,
                selectedArr: i
            }), this.triggerEvent("quesCallback", {
                question: this.data.question,
                site: this.data.site,
                answer: i
            });
        }
    }
});